import {
  Column,
  Entity,
  JoinTable,
  ManyToMany,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { User } from '../../user/entities/user.entity';
import { Menu } from '../../menu/entities/menu.entity';

@Entity()
export class Roles {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  label: string;

  @Column()
  val: string;

  @ManyToMany(() => User, (user) => user.roles)
  @JoinTable({ name: 'role_users' })
  users: User[];

  @ManyToMany(() => Menu, (menu) => menu.roles)
  @JoinTable({ name: 'role_menus' })
  menus: Menu[];
}
